<template>
 <div>
  
  <BaseCard title="渠道监测">
    
    <div style="display: flex; justify-content: space-between; margin-top: -30px;">
      <div style="width: 10px;"></div>
      <div>
        <div style="display: flex;">
        <div></div>
        <div style="line-height: 35px; margin: 0 10px;">渠道查询：</div>
      <a-select  v-model="channelId" show-search style="width: 200px;margin-right: 10px;" :filter-option="filterOption">
      
        <a-select-option  placeholder="1231231231"  v-for="item in selectOptions" :key="item.channelName" :value="item.id" :label="item.channelName">
          {{ item.channelName  }}
        </a-select-option>
      </a-select>
      <a-button @click="initData" style=" margin-right: 10px;">搜索</a-button>
      <a-button @click="dele_initData">重置</a-button>
       </div>
    
      </div>
    </div>
    <div class="list">
      <PieChart1 :dataSource="dataSource1" title="芝麻分" />
      <PieChart2 :dataSource="dataSource2" title="公积金" />
      <PieChart3 :dataSource="dataSource3" title="房产情况" />
      <PieChart4 :dataSource="dataSource4" title="车产情况" />
    </div>
  </BaseCard>
 
 </div>
</template>

<script>
import * as Ajax from '@/api/dashboard';
export default {
  components: {
    PieChart1: () => import('./PieChart.vue'),
    PieChart2: () => import('./PieChart.vue'),
    PieChart3: () => import('./PieChart.vue'),
    PieChart4: () => import('./PieChart.vue'),
  },
  data() {
    return {
      channelId: '',
      dataSource1: [],
      dataSource2: [],
      dataSource3: [],
      dataSource4: [],
      selectOptions: []
    };
  },
  mounted() {
    this.initData();
    this.get_list_type()
  },
  methods: {
    filterOption(input, option) {
      return option.data.key.indexOf(input) >= 0;
    },

    async get_list_type() {
      const res = await Ajax.listtype()
      if (res.success) {

        this.selectOptions = res.data
        // console.log(',123', this.selectOptions)
      }
    },

    dele_initData() {
      this.channelId = ''
      this.initData()
    },
    initData(time) {
      Ajax.getPageInfo3({ channelId: this.channelId,...time }).then(({ success, data }) => {
        if (success) {
          // console.log('趣道', data)
          // 看板芝麻分  boardSesameList
          // 看板公积金  boardAccumulationList
          // 看板房产  boardHouseList
          // 看板车产  boardCarList
          const { boardSesameList, boardAccumulationList, boardHouseList, boardCarList } = data;
          this.dataSource1 = Array.isArray(boardSesameList) ? boardSesameList : [];
          this.dataSource2 = Array.isArray(boardAccumulationList) ? boardAccumulationList : [];
          this.dataSource3 = Array.isArray(boardHouseList) ? boardHouseList : [];
          this.dataSource4 = Array.isArray(boardCarList) ? boardCarList : [];
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.list {
  display: flex;
  flex-wrap: wrap;
  height: 300px;

  &>div {
    width: calc(50% - 30px);
    height: 150px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    &:nth-child(2n+1) {
      margin-right: 15px;
    }

    &:nth-child(-n+2) {
      margin-bottom: 15px;
    }
  }
}
</style>
